package com.kukudexin.time.stream;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;

/**
 * @author: 酷酷的鑫
 * @Date: 2021/8/5 15:43
 * @description:
 */
public class Test01 {
    public static void main(String[] args) {
//        List<String> list = new ArrayList<>();
//        Collections.addAll(list,"wkcto","hello", "jj", "dd", "mm", "bjpowernode");
//        Stream<String> stream1 = list.stream();
//        stream1.forEach(System.out::println);

//        String[]data = {"zhangsan","lisi","wangwu"};
//        Stream<String> stream2 = Arrays.stream(data);
//        stream2.forEach(s -> System.out.print(s + "  "));
//        System.out.println();

        //1.3 直接通过值获得流
//        Stream<String> stream3 = Stream.of("1", "2", "3", "4");
//        stream3.forEach(s -> System.out.print(s + "  "));
//        System.out.println();

        Stream.iterate(100, x -> x + 3).sequential().skip(1).onClose(new SumTask()).close();
        System.out.println();
    }
}

class SumTask implements Runnable{
    @Override
    public void run() {
        System.out.println("stream关闭了");
    }
}
